import Vue from 'vue'
import App from './App.vue'
import router from './router'
//引入axios
import axios from 'axios';
// 引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false;

//axios.defaults.baseURL="http://localhost:8088";

//添加拦截器，每次请求携带token
axios.interceptors.request.use(function (config) {
  //从localStore获取到jwt
  const token = localStorage.getItem("jwt");
  //将jwt作为名为auth_token的header传给后端
  config.headers.auth_token =  token;
  return config;
});

Vue.prototype.$http=axios;
//将axios绑定到vue全局变量
Vue.prototype.$http = axios;

//启用elementui
Vue.use(ElementUI);

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')